package com.fangmao.a28_lib;

import android.app.Activity;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * @ProjectName: wman
 * @Package: com.wman
 * @ClassName: Binding
 * @Description: java类作用描述
 * @Author: wman
 * @CreateDate: 2020/1/14 15:02
 * @UpdateUser: 更新者
 * @UpdateDate: 2020/1/14 15:02
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class Binding {
    public static void bind(Activity activity) {
        try {
            Class bindClass = Class.forName(activity.getClass().getCanonicalName() + "$Binding");
            Class activityClass = Class.forName(activity.getClass().getCanonicalName());
            Constructor constructor = bindClass.getDeclaredConstructor(activityClass);
            constructor.newInstance(activity);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}
